#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 10005;

struct node{
	int x,y;
	int xl,yl;
}cz[maxn];

int cx,cy,n;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>cz[i].x>>cz[i].y>>cz[i].xl>>cz[i].yl;
	}
	cin>>cx>>cy;
	int ans=-1;
	for(int i=1;i<=n;i++){
		if(cz[i].x<=cx && cz[i].x+cz[i].xl>=cx && cz[i].y<=cy && cz[i].y+cz[i].yl>=cy)	ans=i;
	}
	cout<<ans<<endl;
}
